package rec;

/**
 * 一、 递归
 * 3. 反转链表
 * 2024-11-4
 */
class demo3 {
    public ListNode reverseList(ListNode head) {
        if(head == null || head.next == null) return head;

        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next = null;

        return newHead;
    }
}